package cn.wolfcode.luowowo.article.domain;

import cn.wolfcode.luowowo.common.domain.BaseDomain;
import cn.wolfcode.luowowo.common.domain.WendaAnswerComment;
import cn.wolfcode.luowowo.member.domain.UserInfo;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.List;

@Setter
@Getter
public class WendaQuestion extends BaseDomain {
    //自定义提问的问题的状态
    public static final int STATE_REJECT = 0;   //0 禁用
    public static final int STATE_WAITING = 1;  //1 待审核
    public static final int STATE_RELEASE = 2;  //2 发布状态

    private UserInfo author;        // 发布问题的作者
    private String title;           // 问题标题
    private Destination dest;       // 目的地
    private Boolean isHideName;     // 是否匿名提问
    private Integer viewNum=0;      // 问题浏览数量
    private Integer replyNum=0;     // 问题回复数量
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    private Date createTime;        //创建时间
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    private Date replyTime;         //发布时间
    private Boolean ishot=false;    //是否热门
    private Integer state=STATE_WAITING;    //状态
    private List<WendaTag> tags;          //问答标签
    private WendaQuestionContent wendaQuestionContent;  // 提问详情
    private WendaAnswerComment firstAnswer;      //第一个回复的
    public String getStateDisplay(){
        if (state ==STATE_REJECT ){
            return "已拒绝";
        }else if(state ==STATE_WAITING ){
            return "待发布";
        }else if(state ==STATE_RELEASE ){
            return "已发布";
        }
        return "";
    }
}
